package com.suray.system.run.seer.mysql;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.suray.system.run.seer.type.SeerAgvProcess;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SeerTaskDBServiceImpl extends ServiceImpl<SeerTaskDBMapper, SeerTaskDB> implements SeerTaskDBService {

    @Resource
    private SeerTaskDBMapper seerTaskDBMapper;

    @Override
    public List<SeerTaskDB> findUnFinishTask() {
        LambdaQueryWrapper<SeerTaskDB> eq = new QueryWrapper<SeerTaskDB>().lambda()
                .lt(SeerTaskDB::getProcess, SeerAgvProcess.END);

        return this.list(eq);
    }

    @Override
    public void deleteByTime(Integer days) {
        seerTaskDBMapper.deleteTaskForDays(days);
    }
}
